class SubscriptionsController < ApplicationController

  before_filter :authorize, :except => [:search]
  



  # POST /subscriptions
  # POST /subscriptions.json
  def create
    @subscription = Subscription.new(params[:subscription])

    respond_to do |format|
      if @subscription.save
		    format.js
      end
    end
  end

  # DELETE /subscriptions/1
  # DELETE /subscriptions/1.json
  def destroy
    @subscription = Subscription.find(params[:id])
    @subscription.destroy
    
    @markers = getMarkers(@city_name)

    respond_to do |format|
	   format.js
    end
  end

  # POST /subscriptions/search
	def search
    @city_name = params[:city]

    @markers = getMarkers(@city_name)

    respond_to do |format| 
      format.js
    end
	
	end
	

  def update_collapse
    
    @subscription = Subscription.find(params[:id])

    if params[:value] == '1'
      @subscription.update_attributes(:collapsed => '1')
    else
      @subscription.update_attributes(:collapsed => '0')
    end
        
    respond_to do |format| 
      format.js
    end
  end
   
end
